//    Copyright (C) 2007 bigboss
//    bigboss1990@gmail.com
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program; if not, write to the Free Software
//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA


bool aboutEnabled = false;


void Form1::fileExit()
{
    Form1::close();
}

void Form1::aboutme()
{
   system("firefox http://code.google.com/p/popstationmdgui/");
}

int numero_dischi;
void Form1::Avanti()
{
    int i;
    step2->setEnabled(true);
    step1->setEnabled(false);
    numero_dischi = spinBox1->value();

    for ( i = 0; i < numero_dischi; i++)
    {
        Level_compression[i]->setEnabled(true);
        Gamecodes[i]->setEnabled(true);
        Path_File[i]->setEnabled(true);
    }
}
QString main_title; 							/*Titolo PSX*/
QString StringLevel[5];						/*Compression Leve*/
QString StringPath[5]; 						/*Iso Path*/
QString StringGC[5]; 						/*GameCode*/

void Form1::Converti()
{
    QString path_popstation = "./popstation_md"; 	/*Path PopStation*/


    main_title = txt_main_title->text();
    int i;

    /*Livelli Di Compressione*/

    for ( i = 0; i < numero_dischi ; i++)
    {
        StringLevel[i]  	= QString::number(Level_compression[i]->value(),10);
        StringPath[i]  	= Path_File[i]->text();
        StringGC[i]	= Gamecodes[i]->text();
    }
    if (Controlla() == true)
    {
        QString StrConverti,StrConverti2;
        int k;
        StrConverti = path_popstation+" ";
        for ( k = 0; k <= numero_dischi; k++)
        {
            StrConverti += "\"" + main_title + "\" ";
        }
        StrConverti += StringGC[0] + " ";
        for ( k = 0; k <= numero_dischi; k++)
        {
            StrConverti += StringGC[k] + " ";
        }
        for ( k = 0; k < numero_dischi; k++)
        {
            StrConverti += StringLevel[k] + " ";
        }
        for ( k = 0; k < numero_dischi; k++)
        {
            StrConverti += "\"" + StringPath[k] + "\" ";
        }

        system(StrConverti);
    }
}
bool Form1::Controlla()
{
    int i;
    bool result;
    for ( i = 0; i <= numero_dischi; i++ )
    {
        if (StringPath[i] == "")
        {
            loglabel->setText("Path non specificati");
            result = false;
            break;
        }
        else if (StringGC[i] == "")
        {
            loglabel->setText("Gamecodes non inseriti");
            result = false;
            break;
        }
        else if (main_title == "")
        {
            loglabel->setText("Titolo non inserito");
            result = false;
            break;
        }
        else
        {
            result = true;
        }
	
    }
    return result;
}


void Form1::inglese()
{
    textLabel1_3_2_2_3->setGeometry(100, 30, 70, 24);
    textLabel2_2->setGeometry(10, 20, 350, 80);
    pushButton3->setText("Next");
    pbok->setText("Convert");
    textLabel3->setText("<font size=\"-1\">Insert the number of disks</font>");
    textLabel1_3_2_2_3->setText("<font size=\"-1\">Title:</font>");
    groupBox6->setCaption("Compression level:");
    textLabel1_3_2_2_4->setText("<font size=\"-1\">Path:</font>");


}


void Form1::italiano()
{

    textLabel2_2->setGeometry(0,0,0,0);
    pushButton3->setText("Avanti");
    pbok->setText("Converti");
    textLabel3->setText("<font size=\"-1\">Inserire il numero dei dischi</font>:");
    textLabel1_3_2_2_3->setText("<font size=\"-1\">Titolo del gioco:</font>");
    groupBox6->setCaption("Livelli di compressione:");
    textLabel1_3_2_2_4->setText("<font size=\"-1\">Path:</font>");
    textLabel1_3_2_2_3->setGeometry(100, 30, 80, 24);

}
